<template>
  <section class="jumbotron">
    <h3 class="jumbotron-heading">Search Github Users</h3>
    <div>
      <input
        type="text"
        placeholder="enter the name you search"
        ref="keyword"
      />&nbsp;<button @click="handler">Search</button>
    </div>
  </section>
</template>

<script>
export default {
  name: "",
  methods: {
    //按钮的回调函数
    handler(){
     //先获取input文本内容
     let keyword = this.$refs.keyword.value;
     //关键字不能为空
     if(keyword.trim()=='') return;//今天把正则稍微复习一下
     //触发自定义事件：给兄弟组件传递数据
     this.$bus.$emit('sendKeyword',keyword);
    }
  }
};
</script>

<style scoped>
</style>
